package demon1;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import javax.xml.crypto.Data;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Test {
    public static void main(String[] args) throws SQLException {
//        DataSource dataSource=new MysqlDataSource();
//        ((MysqlDataSource) dataSource).setUrl("jdbc:mysql://127.0.0.1:3306" +
//                "/bit32mall?characterEncoding=utf8&useSSl=false");
//        ((MysqlDataSource)dataSource).setUser("root");
//        ((MysqlDataSource)dataSource).setPassword("123qwe...");
//        Connection connection=dataSource.getConnection();
//        String sql="select * from bag";
//        PreparedStatement statement=connection.prepareStatement(sql);
//        ResultSet resultSet=statement.executeQuery();
//        while(resultSet.next()){
//            int a=resultSet.getInt("price");
//            int b=resultSet.getInt("inventory");
//            System.out.println(a+"\t"+b);
//        }
        DataSource dataSource=new MysqlDataSource();
        ((MysqlDataSource)dataSource).setPassword("123qwe...");
        ((MysqlDataSource)dataSource).setUser("root");
        ((MysqlDataSource)dataSource).setUrl("jdbc:mysql://127.0.0.1:3306/bit32mall?characterEncoding=utf8&useSSl=false");
        Connection connection=dataSource.getConnection();
        String sql="";
        PreparedStatement statement=connection.prepareStatement(sql);
        ResultSet resultSet =statement.executeQuery();
    }
}
